package com.tyut.websocket;


import jakarta.websocket.*;
import jakarta.websocket.server.ServerEndpoint;
import org.springframework.stereotype.Component;

@Component
@ServerEndpoint("/game/link")
public class GameWebSocket {
    @OnOpen
    public void onOpen(Session session) {
        System.out.println("WebSocket连接已开启");
    }

    @OnClose
    public void onClose(Session session) {
        System.out.println("WebSocket连接已关闭");
    }

    @OnMessage
    public void onMessage(String message, Session session) {
        System.out.println("收到客户端消息：" + message);
    }

    @OnError
    public void onError(Session session, Throwable throwable) {
        System.out.println("WebSocket连接发生错误：" + throwable.getMessage());
    }
}
